<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>学生奖学金信息申请审核</title>
<%@ include file="/module/js.jsp"%>
<script type="text/javascript">
$(document).ready(
		function() {
			$('#dg').datagrid({
			/*onSortColumn :function(sort,order){
			   var _sort=sort;
			   var _order=order;
			   var options=$('#dg').datagrid('getPager').data("pagination").options;
			   var page=options.pageNumber;
			   var pageSize=options.pageSize;
			   window.setTimeout(function(){
				   $.post("${basePath}/scholarship/scholarshipStudentManagerList",{orderFlag:_order,orderField:_sort,
					   xnd: $('#xnd').val(),njid:$("#njid").val(),zyid:$("#zyid").val(),bjid:$("#bjid").val(),xm:$("#xm").val(),xh:$("#xh").val(),
					   bzr:$("#ismanager").val()
					   },function(data){
							  $('#dg').datagrid("loadData",data); 
						   });
				 },100);  
			   },*/
			   rowStyler: function(index,row){
			   }
			});
 		 //columnWidthAutoResize('dg',new Array("zymc"));
			//查询
			$('#btnQuery').click(function() {
			  $('#dg').datagrid('load',{
				  xnd: $('#xnd').val(),njid:$("#njid").val(),zyid:$("#zyid").val(),bjid:$("#bjid").val(),xm:$("#xm").val(),xh:$("#xh").val(),
				  ismanager :$("#ismanager").val()
			  });
			});
		    //导出列表
			$('#btnExport').on('click', function(){
				   layer.confirm("您确定要导出吗?", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
					  // var rows = $("#dg").datagrid("getRows");
					  // var bodyData = JSON.stringify(rows);  //转成json字符串
					   /// $("#bodyData").val(JSON.stringify(rows));
							document.scholarshipForm.action = "${basePath}/scholarship/exportManagerStudentScholarshipApply";
							document.scholarshipForm.submit();
         		 });
				});
		    //导出班级汇总
			$('#btnClassExport').on('click', function(){
				var xnd=$("#xnd").val();
				var bjid=$("#bjid").val();
				var ismanager=$("#ismanager").val();
				if(xnd==""||bjid==""){
				  layer.alert("请您选择学年和班级", {icon: 6});
       		       return false;		
				}else{
					  layer.confirm("您确定要导出吗?", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
						  $("#scholarshipStudentReportDeatail").html(""); 
				    		$.ajax({
				                type: "post",
				                url: "${basePath}/scholarship/getStudentScholarshipReport",
				                data: {xnd:xnd,bjid:bjid,bzr :ismanager},
				                success: function(data){
				                 $("#scholarshipStudentReportDeatail").html(data);
				                 expStatXls("exportClassReport","交通职高"+xnd+"学年奖学金名单汇总表");
				                }
				   	   		}); 	
	         		 });	
				}
				});
		});


function formaterLink(value, row, index) {
    return "<a href='${basePath}/scholarship/viewStudentScholarshipManagerForward?sqid=" + row.sqid+"&bzr=${ismanager}'>" + value + "</a>";
}
function expStatXls(_tableId,_fileName){
		var tables=_tableId.split(",");
		var titles=_fileName.split(",");
		var _paramRowsLength="";
		var _paramColsLength="";
		var _statfileName="";
		var _statParamAllContent="";
		var _statParamHead="";
		for(var t=0;t<tables.length;t++){
			 var table=document.getElementById(tables[t]);
		     var rows=table.getElementsByTagName('tr');
		     var cells;	
		     var cell;	         
		     var j;
		     var colsLength=0;
		     var strArr=new Array(); 
		     var strHead='';
		     var subIdx=0;
		     var varTmpCont;
		     var strIndx=-1;
		     var flag=false;//false 表示 是th
		     var cellColor='';
		     for(var i=0;i<rows.length;i++){
	        	  try{
	        	    cells=table.rows[i].getElementsByTagName('th');
	        	    flag=false;
	        	    if(cells.length==0){
	        	      cells=table.rows[i].getElementsByTagName('td');
	        	      flag=true;
	        	    }
	        	  }catch(e){
	        	    cells=table.rows[i].getElementsByTagName('td');
	        	    flag=true;		         	    
	        	  }				         	         	 
	        	  for(j=0;j<cells.length;j++){
	        	  	  strIndx=-1;
	        	  	  cell=table.rows[i].cells[j];
	        	  	 //cell=cells[j];
	        	  	  if(i==0){
	        	  	     colsLength=colsLength+cell.colSpan;	
	        	  	     if(j==0){
	        	  	       strArr[subIdx]='';
	        	  	     }
	        	  	  }					             	  	  		         	  	
	        	  	  if(i%300==0 && i>0){
	        	  	      if(j==0){
	        	  	        subIdx++;
	        	  	        strArr[subIdx]='';
	        	  	      }
	        	  	  }	
	        	  	
	        	  	  varTmpCont=cell.innerHTML.replace(/(^\s*)|(\s*$)/g, "");			         	  	        	  	     
	        	  	  varTmpCont=varTmpCont.replace(/<\/A>/gi, ""); 
	        	  	  varTmpCont=varTmpCont.replace(/<\/SPAN>/gi, "");		         	  	  
	        	  	  varTmpCont=varTmpCont.replace(/&nbsp;/gi, "");
	        	  	if(cell.style !=null && cell.style!= undefined && cell.style!= ''){
	        	  	  //if(cell.getAttribute("style") !=null && cell.getAttribute("style")!= undefined && cell.getAttribute("style")!= ''){
	        	  	    // cellColor = cell.getAttribute("style").getAttribute("color");
	        	  	     //cellColor = cell.style.color;
	        	  	     cellColor="red";
	        	  	     if(cellColor!=null && cellColor == 'red'){
	        	  	        cellColor = "R";
	        	  	     }else if(cellColor!=null && cellColor == 'green'){
	        	  	       cellColor = "G";
	        	  	     }	         	  	    
	        	  	  }        	  	  	         	  	
	        	  	  strIndx=varTmpCont.lastIndexOf('>');
	        	  	  if(strIndx!=-1){
	        	  	       varTmpCont=varTmpCont.substring(strIndx+1,varTmpCont.length);
	        	  	  }
	        	  	  strArr[subIdx]=strArr[subIdx].concat(varTmpCont+","+cell.rowSpan+","+cell.colSpan+","+cellColor+","+j+"CC");
	        	  	  if(!flag){
	        	  	    if(varTmpCont==')'){
	        	  	       varTmpCont=cell.innerHTML;
	        	  	    }
	        	  	    strHead=strHead.concat(varTmpCont+","+cell.rowSpan+","+cell.colSpan+","+cellColor+","+$(cell).attr("y")+"CC");		         	  	  
	        	  	  }			         	  	  		         	  	  
	        	  	}		         	  			         	  	
	        	  	 strArr[subIdx]=strArr[subIdx].concat("LL");
	        	  	  if(!flag){
	        	  	    strHead=strHead.concat("LL");		         	  	    
	        	  	  }
	        	  			  		         	  
	        	}  
		     //
		     var strContent='';	 
		        for(var k=0;k<strArr.length;k++){
		            strContent=strContent.concat(strArr[k]);
		     }
		     if(_paramRowsLength==""){
		    	 _paramRowsLength=rows.length; 
		     }else{
		    	 _paramRowsLength=_paramRowsLength+"-"+rows.length;
		     }
		     if(_paramColsLength==""){
		    	 _paramColsLength=colsLength;
		     }else{
		    	 _paramColsLength=_paramColsLength+"-"+colsLength;	 
		     }
		    if(_statfileName==""){
		    	_statfileName=titles[t];
		    }else{
		    	_statfileName=_statfileName+"-"+titles[t];
		    }
		    if(_statParamAllContent==""){
		    	_statParamAllContent=strContent;
		    }else{
		    	_statParamAllContent=_statParamAllContent+"-"+strContent;
		    }
		    if(_statParamHead==""){
		    _statParamHead=strHead;	
		    }else{
		     _statParamHead=_statParamHead+"-"+strHead;
		    }
		   
		}
       var param="paramRowsLength="+_paramRowsLength+"&paramColsLength="+_paramColsLength;
       document.getElementById('statfileName').value=_statfileName;
       document.getElementById('statParamAllContent').value=_statParamAllContent;
       document.getElementById('statParamHead').value=_statParamHead;
      document.scholarshipForm.action="${basePath}/scholarship/exportManagerClassStudentScholarshipApply?"+param;
       document.scholarshipForm.submit();		            		        
  }
</script>


</head>
<body>
	<form action="#" name="scholarshipForm" id="scholarshipForm" method="post">
<!-- 	  <input  type="hidden" id="bodyData" name="bodyData"/> -->
	  <input type="hidden" id="statfileName" name="fileName" value="" />	
	<input type="hidden" id="statParamAllContent" name="paramAllContent" value="" />
	<input type="hidden" id="statParamHead" name="paramHead" value="" />
	<input type="hidden" id="ismanager" name="ismanager" value="${ismanager}" />
		<table cellpadding="1" cellspacing="1" border="0">
			<tr>
				<td><input type="button" id="btnQuery" autocomplete="off"  value="查询"
					class="inputButton" /></td>
				<td><input type="button" id="btnExport" autocomplete="off"  value="导出列表"
				class="inputButton" /></td>
				<td><input type="button" id="btnClassExport" autocomplete="off"  value="导出班级汇总表"
				class="inputButton" /></td>
			</tr>
		</table>
		<table cellpadding="1" cellspacing="1">
			<tr>
				<td>学年：</td>
				<td>
				<select id="xnd" name="xnd" class="selectList2">
				 <option value="">全部</option>
				 <c:forEach items="${yearList}" var="y">
				 <option value="${y.xnd}">${y.xnd}</option>
				 </c:forEach>
				</select>
			</td>
			<td>学号：</td>
			<td><input type="text"  id="xh" name="xh" value="" autocomplete="off" class="inputText2"/></td>
			<td>姓名：</td>
			<td><input type="text"  id="xm" name="xm" value="" autocmplete="off" class="inputText2"/></td>
			</tr>
			<%@ include file="/module/gradeSpecityByClass.jsp"%>
		</table>
		<br/>
     <table id="dg"  style="width:100%;"
		data-options="pagination:true,collapsible:true,url:'${basePath}/scholarship/scholarshipStudentManagerList?bzr=${ismanager}',method:'post',remoteSort:true,striped:true">
		<thead>
			<tr>
<!-- 				<th data-options="field:'sqid',checkbox:true,width:100,align:'center'"></th> -->
				<th data-options="field:'xm',sortable:true,nowrap:true,width:200,align:'center',formatter:formaterLink">姓名</th>
				<th data-options="field:'xh',sortable:true,nowrap:true,width:200,align:'center'">学号</th>
				<th data-options="field:'bjmc',sortable:true,nowrap:true,width:200,align:'center'">班级</th>
				<th data-options="field:'zymc',sortable:true,nowrap:true,width:300,align:'center'">专业</th>
				<th data-options="field:'njmc',sortable:true,nowrap:true,width:200,align:'center'">年级</th>
				<th data-options="field:'xnd',sortable:true,nowrap:true,width:200,align:'center'">学年</th>
				<th data-options="field:'jxjdj',sortable:true,nowrap:true,width:200,align:'center'">奖学金等级</th>
			</tr>
		</thead>
	</table>
	 <div  id="scholarshipStudentReportDeatail" style="display: none;">
	 </div>
	
		<script type="text/javascript">
			 if("${msg}"!=""){
			       layer.alert("${msg}", {icon: 6});
			  } 
			 compareListValue(document.getElementById('xnd'),'${xnd}');
			 
		</script>
	</form>
</body>
</html>
